﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Ajax_blueDq1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpContext c = HttpContext.Current;
       string dateTimeStr = "";
        string dateTimeAddtime = "";
        string buleball = "";
        string buleballws = "";
        string buleballjo = "";
        string buleballwsss = "";
        string buleballdx = "";
        string buleballsanlu = "";
        string buleballsilu = "";
        int lotteryType = ReadRequest.RequestInt("type");
        int count = ReadRequest.RequestInt("counts");
        int qsType = ReadRequest.RequestInt("qsType");
        int totalCount = 0;
        string sql = "";
        if (qsType == 1)
        {
            sql = " LotteryType =" + lotteryType + " and LotteryQS% 2= 1";
        }
        else if (qsType == 2)
        {
            sql = " LotteryType =" + lotteryType + " and LotteryQS% 2= 0";
        }
        else if (qsType == 3)
        {
            sql = " LotteryType =" + lotteryType + " and datepart(weekday,openTime)=3";//周二
        }
        else if (qsType == 4)
        {
            sql = " LotteryType =" + lotteryType + " and datepart(weekday,openTime)=5";//周四
        }
        else if (qsType == 5)
        {
            sql = " LotteryType =" + lotteryType + " and datepart(weekday,openTime)=1";//周日
        }
        List<Model.LotteryAnnouncement> modellist = BLL.LotteryAnnouncement.GetPageListSQl(0, count, sql, out totalCount);
        //for (int i = 0; i < modellist.Count; i++)
        for (int i = modellist.Count - 1; i >= 0; i--)
        {
            string flag = modellist[i].LotteryNo.Split('+')[1];
            dateTimeStr += modellist[i].LotteryQS + ",";
            dateTimeAddtime += modellist[i].openTime.Year + "-" + modellist[i].openTime.Month + "-" + modellist[i].openTime.Day + ",";
            buleball += flag + ",";
            buleballws += flag.Substring(flag.Length - 1, 1) + ",";//蓝球尾数
			buleballwsss = flag.Substring(flag.Length - 1, 1);
            if (int.Parse(flag) % 2 == 0)
            {
                buleballjo+= "1"+ ","; //双
            }
            else
            {
                buleballjo+= "0"+ ","; //单
            }
            int a = int.Parse(flag);
            if ((int.Parse(buleballwsss) >= 6 && int.Parse(buleballwsss) <=9) || (int.Parse(buleballwsss) == 0))
            {
                buleballdx += "0" + ","; //大 
            }
            else if (int.Parse(buleballwsss) >= 1 && int.Parse(buleballwsss) <=5)
            {
                buleballdx += "1" + ","; //小 
            }
            if (int.Parse(buleballwsss)  % 3 == 0)
            {
                buleballsanlu += "0" + ","; //三路0
            }
            else if (int.Parse(buleballwsss) % 3 == 1)
            {
                buleballsanlu += "1" + ","; //三路1
            }
            else if (int.Parse(buleballwsss) % 3 == 2)
            {
                buleballsanlu += "2" + ","; //三路2
            }

            if (int.Parse(buleballwsss) >= 1 && int.Parse(buleballwsss) <= 4)
            {
                buleballsilu += "1" + ","; //4路0 
            }
            else if (int.Parse(buleballwsss) >= 5 && int.Parse(buleballwsss) <= 8)
            {
                buleballsilu += "2" + ","; //4路1 
            }
            else if (int.Parse(buleballwsss) >= 9 && int.Parse(buleballwsss) <= 12)
            {
                buleballsilu += "3" + ","; //4路2
            }
            else if (int.Parse(buleballwsss) >= 13 && int.Parse(buleballwsss) <= 16)
            {
                buleballsilu += "4" + ","; //4路3
            }
        }
        dateTimeStr = dateTimeStr.TrimEnd(',');
        dateTimeAddtime = dateTimeAddtime.TrimEnd(',');
        buleball = buleball.TrimEnd(',');
        buleballws = buleballws.TrimEnd(',');
        buleballjo = buleballjo.TrimEnd(',');
        buleballdx = buleballdx.TrimEnd(',');
        buleballsanlu = buleballsanlu.TrimEnd(',');
        buleballsilu = buleballsilu.TrimEnd(',');
        Response.Write(dateTimeStr + "*" + dateTimeAddtime + "*" + buleball + "*" + buleballws + "*" + buleballjo + "*" + buleballdx + "*" + buleballsanlu + "*" + buleballsilu);
        Response.End();
    }
}